package cn.wp.ewallet.upms.dao.impl;

import cn.wp.common.core.cache.WpCacheGroup;
import cn.wp.common.core.dao.JdbcSupportTemplate;
import cn.wp.ewallet.upms.dao.LoginLogDao;
import cn.wp.ewallet.upms.model.entity.LoginLogDo;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Repository;

/**
 * 登录日志数据访问层
 * Created by chenyb on 2019/10/21
 */
@Repository
public class LoginLogDaoImpl implements LoginLogDao {

    @Autowired
    private JdbcSupportTemplate jdbcSupportTemplate;

    @Autowired
    private WpCacheGroup wpCacheGroup;

    @Override
    public int insertLoginLog(LoginLogDo loginLogDo) {
        return jdbcSupportTemplate.insert(loginLogDo);
    }

    @Override
    public int insertLoginEquipment(String account,String uuid) {
        if(account != null && uuid != null){
            wpCacheGroup.getCache("login-equipment-cache").set(account,uuid);
        }
         return 1;
    }

    @Override
    public String selectLastLoginEquipment(String account) {
        if(account == null){
            return "";
        }
        return wpCacheGroup.getCache("login-equipment-cache").get(account);
    }

}
